//
//  PickerChoseAddressView.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/30.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "PickerChoseAddressView.h"
#import "AppDelegate.h"
#import "CommonMacro.h"


#define KComponentCount 3
#define KProvinceComponent 0
#define KCityComponent 1
#define KAreaComponet 2
#define KComponent 3

@interface PickerChoseAddressView ()
@property (nonatomic,strong) UIView *bgView;
@property (nonatomic,strong) UIView *myBgView;

@end

@implementation PickerChoseAddressView

- (void)viewDidLoad {
    [super viewDidLoad];
   
}

- (void)pickerChooseAddressView
{
    UIWindow *window = [[UIApplication sharedApplication].delegate window];
    self.bgView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [window addSubview:self.bgView];
    self.bgView.backgroundColor = [UIColor blackColor];
    self.bgView.alpha = 0.5;
    
    self.myBgView = [[UIView alloc] initWithFrame:CGRectMake(10, self.bgView.frame.size.height*0.3, self.bgView.frame.size.width-20, self.bgView.frame.size.height*0.5)];
    [window addSubview:self.myBgView];
    self.myBgView.backgroundColor = [UIColor whiteColor];
    
    self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(10, 10, self.myBgView.frame.size.width-20, self.bgView.frame.size.height*0.5)];
    [self.myBgView addSubview:self.pickerView];
    self.pickerView.dataSource = self;
    self.pickerView.delegate = self;
    self.pickerView.backgroundColor = [UIColor blueColor];
    
    
    provinceArr = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"area.plist" ofType:nil]];
    cityArr = [[provinceArr objectAtIndex:0] objectForKey:@"cities"];
    
    areaArr = [[cityArr objectAtIndex:0] objectForKey:@"city"];
    
   
}

//返回多少列
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    return KComponentCount;
}

//每列中有多少行
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
//    if (component==KProvinceComponent) {
//        return animalNames.count;
//    }
//    else if (component==KSoundComponent){
//        return animalSounds.count;
//    }
        return 4;
}

//每列的宽度
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component{
//        if (component==KAnimalComponent) {
            return 75;
//        }
//        else{
//            return 150;
//        }
}

//每行的高度
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component{
    return 55;
}

//每列每行的内容
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
//    if (component==KAnimalComponent) {
//        UILabel *animal=[[UILabel alloc]init];
//        animal.backgroundColor=[UIColor clearColor];
//        animal.text=animalNames[row];
//        return animal;
//    }
//    else{
//        UILabel *soundLabel=[[UILabel alloc]init];
//        soundLabel.backgroundColor=[UIColor clearColor];
//        soundLabel.text=animalSounds[row];
//        return soundLabel;
//    }
    return pickerView;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
